﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Biblio2.LocalParsing
{
    public partial class Step1UserControl : UserControl
    {
        #region Attributs
        
        #endregion Attributs

        #region Constructeur
        public Step1UserControl()
        {
            InitializeComponent();
        }
        #endregion Constructeur

        #region Accesseurs

        #endregion Accesseurs

        #region Progress
        public void ReportProgress(LocalParsingManager.Step aStep, int aValue, int aMaxValue)
        {
            Label labelProgress = null;
            ProgressBar bar = null;
            switch (aStep)
            {
                case LocalParsingManager.Step.Step1_1:
                    labelProgress = step11Label;
                    labelProgress.Text = "Dossier ";
                    bar = step11ProgressBar;
                    break;
                case LocalParsingManager.Step.Step1_2:
                    labelProgress = step12Label;
                    labelProgress.Text = "Fichier ";
                    bar = step12ProgressBar;
                    break;
                case LocalParsingManager.Step.Step1_3:
                    labelProgress = step13Label;
                    labelProgress.Text = "Fichier ";
                    bar = step13ProgressBar;
                    break;
                case LocalParsingManager.Step.Step1_4:
                    labelProgress = step14Label;
                    labelProgress.Text = "Fichier Complet ";
                    bar = step14ProgressBar;
                    break;
            }

            if (labelProgress != null)
                labelProgress.Text += aValue.ToString() + "/" + aMaxValue.ToString();

            if (bar != null)
            {
                bar.Maximum = aMaxValue;
                if (aValue > aMaxValue)
                    bar.Value = aMaxValue;
                else
                    bar.Value = aValue;
            }
        }

        public void ReportProgress(LocalParsingManager.Step aStep, String aMsg)
        {
            Label labelMessage = null;
            switch (aStep)
            {
                case LocalParsingManager.Step.Step1_1:
                    labelMessage = step11MessageLabel;
                    break;
                case LocalParsingManager.Step.Step1_2:
                    labelMessage = step12MessageLabel;
                    break;
                case LocalParsingManager.Step.Step1_3:
                    labelMessage = step13MessageLabel;
                    break;
                case LocalParsingManager.Step.Step1_4:
                    labelMessage = step14MessageLabel;
                    break;
            }

            if (labelMessage != null)
                labelMessage.Text = aMsg;
        }

        public void ReportError(LocalParsingManager.Step aStep, String anError)
        {
            Label labelError = null;
            switch (aStep)
            {
                case LocalParsingManager.Step.Step1_1:
                    labelError = step11ErrorLabel;
                    break;
                case LocalParsingManager.Step.Step1_2:
                    labelError = step12ErrorLabel;
                    break;
                case LocalParsingManager.Step.Step1_3:
                    labelError = step13ErrorLabel;
                    break;
                case LocalParsingManager.Step.Step1_4:
                    labelError = step14ErrorLabel;
                    break;
            }

            if (labelError != null)
                labelError.Text = anError;
        }
        #endregion Progress

        #region Start

        #endregion Start

        #region Init
        public void Init()
        {
            //step11PictureBox
            ReportProgress(LocalParsingManager.Step.Step1_1, 0, 1);
            ReportProgress(LocalParsingManager.Step.Step1_1, String.Empty);
            ReportError(LocalParsingManager.Step.Step1_1, String.Empty);

            ReportProgress(LocalParsingManager.Step.Step1_2, 0, 1);
            ReportProgress(LocalParsingManager.Step.Step1_2, String.Empty);
            ReportError(LocalParsingManager.Step.Step1_2, String.Empty);

            ReportProgress(LocalParsingManager.Step.Step1_3, 0, 1);
            ReportProgress(LocalParsingManager.Step.Step1_3, String.Empty);
            ReportError(LocalParsingManager.Step.Step1_3, String.Empty);

            ReportProgress(LocalParsingManager.Step.Step1_4, 0, 1);
            ReportProgress(LocalParsingManager.Step.Step1_4, String.Empty);
            ReportError(LocalParsingManager.Step.Step1_4, String.Empty);
        }
        #endregion Init
    }
}
